'use strict'
import { QueryInterface, DataTypes } from 'sequelize'
import bcrypt from 'bcryptjs'
import dayjs = require('dayjs')

/** @type {import('sequelize-cli').Migration} */
module.exports = {
  async up(queryInterface: QueryInterface, Sequelize: typeof DataTypes) {
    await queryInterface.bulkInsert(
      'Users',
      [
        {
          email: 'admin@qq.com',
          username: 'admin',
          password: bcrypt.hashSync('123456'),
          nickname: '超厉害的管理员',
          avatar:
            'https://clwy-stu.oss-cn-shanghai.aliyuncs.com/uploads/0e58447c-107d-4ebb-b5ed-a0e8d3a1bd55.JPG',
          gender: 2,
          roleId: 100,
          expiredAt: dayjs().add(1, 'year').toDate(),
          createdAt: new Date(),
          updatedAt: new Date(),
        },
        {
          email: 'user2@qq.com',
          username: 'user2',
          password: bcrypt.hashSync('123456'),
          nickname: '库存用户2',
          gender: 0,
          roleId: 2,
          expiredAt: new Date(),
          createdAt: new Date(),
          updatedAt: new Date(),
        },
        {
          email: 'user3@qq.com',
          username: 'user3',
          password: bcrypt.hashSync('123456'),
          nickname: '普通用户3',
          gender: 2,
          roleId: 1,
          expiredAt: new Date(),
          createdAt: new Date(),
          updatedAt: new Date(),
        },
        {
          email: 'user4@qq.com',
          username: 'user4',
          password: bcrypt.hashSync('123456'),
          nickname: '普通用户4',
          gender: 1,
          roleId: 1,
          expiredAt: new Date(),
          createdAt: new Date(),
          updatedAt: new Date(),
        },
      ],
      {},
    )
  },

  async down(queryInterface: QueryInterface, Sequelize: typeof DataTypes) {
    await queryInterface.bulkDelete('Users', [], {})
  },
}
